package com.xh.sys.vo.webform;

import com.mybatisflex.core.query.QueryWrapper;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

import static com.xh.sys.entity.table.SysCommentBackTableDef.SYS_COMMENT_BACK;


@Data
@Builder //默认是全参的 会使无参失效 需要都声明构造
@NoArgsConstructor
@AllArgsConstructor
public class SysCommentBackQuery {

    @NotNull(message = "type不能空")
    private Integer type;
    @NotBlank(message = "key不能空")
    private String key;
    @NotBlank(message = "value不能空")
    private String value;

    public QueryWrapper queryWrapperBuild() {
        QueryWrapper queryWrapper = QueryWrapper.create()
                .select(SYS_COMMENT_BACK.DEFAULT_COLUMNS)
                .from(SYS_COMMENT_BACK)
                .and(SYS_COMMENT_BACK.TYPE.eq(type))
                .and(SYS_COMMENT_BACK.KEY.eq(key))
                .and(SYS_COMMENT_BACK.VALUE.eq(value));

        return queryWrapper;
    }
}
